-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate UI Framework source into Kibana. #9192
Migrate UI Framework source into Kibana. #9192
Conversation
- Add dependencies to package.json. - Add task for building UI Framework docs and serving locally. - Import UI Framework scss from autoload/styles.js instead of importing the CSS in base.less.
40a96e5
to
de3f34f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quick comment and a question
@@ -62,7 +62,8 @@ | |||
"makelogs": "makelogs", | |||
"mocha": "mocha", | |||
"mocha:debug": "mocha --debug-brk", | |||
"sterilize": "grunt sterilize" | |||
"sterilize": "grunt sterilize", | |||
"uiFramework:start": "./node_modules/.bin/webpack-dev-server --config src/ui_framework/webpack.config.js --hot --inline --content-base src/ui_framework/public/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need ./node_modules/.bin/
when running npm scripts, the node_modules/.bin
is included in the path by default in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks man!
"npm": "3.10.8", | ||
"numeral": "1.5.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think numeral has caused us some issues in the past, though I suspect your use is probably fine. Curious what you're using it for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I don't think it's actually being used anywhere. Thanks for catching this, I'll remove it.
What do you think about unifying source related to the ui framework's doc site in I'm thinking:
|
@spalger That's a really good idea. I'll implement your suggestion. Out of curiosity, what are the additional meanings/baggage you associate with the |
In the context of plugins, |
@w33ble Ah OK yeah, that makes sense in the context of Kibana. I was wondering if there was a broader convention beyond Kibana I wasn't familiar with. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quick dependency question
@@ -91,6 +92,7 @@ | |||
"babel": "5.8.38", | |||
"babel-core": "5.8.38", | |||
"babel-loader": "5.3.2", | |||
"babel-polyfill": "6.9.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be using some v5 of this plugin? Is it compatible with our current Babel 5 setup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch man, looks like this isn't needed at all since we're using 5, not 6.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems really close but I have a few quibbles. The major one that I didn't bring up in inline comments, because it's pretty wide-spread, is the use of default exports. It's a pretty new rules that we have choosen to follow, but I think it would be a good idea to update this code to that standard before merging it.
There's at least one typo it would have prevented :) (creatExample
)
@@ -108,6 +108,10 @@ class BaseOptimizer { | |||
`css${mapQ}!autoprefixer${mapQPre}{ "browsers": ["last 2 versions","> 5%"] }!less${mapQPre}dumpLineNumbers=comments` | |||
) | |||
}, | |||
{ | |||
test: /\.scss$/, | |||
loaders: ['style', 'css', 'sass'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably should be using the ExtractTextPlugin
so the CSS is included synchronously, before the JS (which loads asynchronously):
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract(
'style',
`css${mapQ}!autoprefixer${mapQPre}{ "browsers": ["last 2 versions","> 5%"] }!sass${mapQPre}`
)
}
|
||
In short: we've outgrown it! Third-party CSS frameworks like Bootstrap and Foundation are designed | ||
for a general audience, so they offer things we don't need and _don't_ offer things we _do_ need. | ||
As a result, we've forced to override their styles until the original framework is no longer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we've been
or we're
?
GuideExample, | ||
} from '../../components'; | ||
|
||
export default function creatExample(examples) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misspelled createExample()
|
||
export default class GuideExample extends Component { | ||
|
||
constructor(props, sections) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing a second argument to the constructor of a component perplexed me at first (especially since the second argument that components normally take is context).
I wonder if it would be less confusing if this class was defined inside the createExample
function, and the closure was used to give that example component it's sections
/examples
.
(I also think createExample()
could use a bit more color in it's name)
export function createExampleComponent(sections) {
return class ExampleCompoent extends Component {
// ...
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you have a really interesting point, but I'd like to avoid too much re-architecting of how the docs site works within this PR -- I just want to focus on getting it integrated with Kibana for now, so we can unblock UI development. I'm totally open to refactoring it later though. :)
|
||
import ActionTypes from '../action_types'; | ||
|
||
export default { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's generally preferable to expose each value explicitly, rather than an object of named values.
ie.
export const openCodeViewer = slug => ({
type: ActionTypes.OPEN_CODE_VIEWER,
slug,
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here; good point but let's do this later.
|
||
export default class GuideCodeViewer extends Component { | ||
|
||
constructor(props) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary constructor, there are a few others
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here... though I'm thinking once we add the linting rule for this, we can get rid of them all at once.
@@ -0,0 +1,21 @@ | |||
|
|||
export * from './guide_code_viewer/guide_code_viewer.jsx'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file seems to be exporting too much. Also, just like all other imports these imports should not have extensions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same... can we do this later?
@@ -0,0 +1,12 @@ | |||
|
|||
export * from './example/createExample'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another example of what looks like over-exporting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same... can we do this later?
@spalger Can you take another look? I addressed a few of your comments but I'd like to address the majority of them in subsequent PRs. I'd like to keep this PR focused on integrating the UI Framework as it already exists, so we can unblock UI dev (I'm continuing to work on the existing UI Framework and the longer this PR is left unmerged the more difficult it will be to port the changes over). |
Sounds good to me @cjcenizal |
Code works as described. I run the commands, I get a running version of the framework. I'm not familiar with the vast majority of the stack here though, so I can't really give you considered input on that part. I would like to say that I think it would be helpful to outline the conventions in the framework itself. Things like how you name classes with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - as it's been discussed we're simply reviewing how this project is to be brought into Kibana and saving the code change for another day.
## Development | ||
|
||
* Start development server `npm run uiFramework:start`. | ||
* View docs on `http://localhost:8080/`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8080 is a common, and the default port for webpack dev server. We will probably want to change this in the future to avoid collisions.
|
||
## Examples of other in-house UI frameworks | ||
|
||
* [Ubiquiti CSS Framework](http://ubnt-css.herokuapp.com/#/app/popover) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't you make this? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure did!
Backports PR #9192 **Commit 1:** Migrate UI Framework source into Kibana. - Add dependencies to package.json. - Add task for building UI Framework docs and serving locally. - Import UI Framework scss from autoload/styles.js instead of importing the CSS in base.less. * Original sha: de3f34f * Authored by CJ Cenizal <[email protected]> on 2016-11-22T22:27:11Z **Commit 2:** Refactor UI Framework directory structure. * Original sha: 4e54844 * Authored by CJ Cenizal <[email protected]> on 2016-12-05T23:03:01Z **Commit 3:** Remove babel-polyfill. * Original sha: 43854bc * Authored by CJ Cenizal <[email protected]> on 2016-12-05T23:47:42Z **Commit 4:** Fix typos and include SCSS synchronously. * Original sha: fe5bab1 * Authored by CJ Cenizal <[email protected]> on 2016-12-10T00:33:17Z **Commit 5:** Update with latest changes to UI Framework. * Original sha: a44140a * Authored by CJ Cenizal <[email protected]> on 2016-12-13T01:47:09Z
Backports PR #9192 **Commit 1:** Migrate UI Framework source into Kibana. - Add dependencies to package.json. - Add task for building UI Framework docs and serving locally. - Import UI Framework scss from autoload/styles.js instead of importing the CSS in base.less. * Original sha: de3f34f * Authored by CJ Cenizal <[email protected]> on 2016-11-22T22:27:11Z **Commit 2:** Refactor UI Framework directory structure. * Original sha: 4e54844 * Authored by CJ Cenizal <[email protected]> on 2016-12-05T23:03:01Z **Commit 3:** Remove babel-polyfill. * Original sha: 43854bc * Authored by CJ Cenizal <[email protected]> on 2016-12-05T23:47:42Z **Commit 4:** Fix typos and include SCSS synchronously. * Original sha: fe5bab1 * Authored by CJ Cenizal <[email protected]> on 2016-12-10T00:33:17Z **Commit 5:** Update with latest changes to UI Framework. * Original sha: a44140a * Authored by CJ Cenizal <[email protected]> on 2016-12-13T01:47:09Z
Addresses #8867
When we make changes to our UI by adding new components to the UI Framework, our dev process will look like this:
npm start
.npm run uiFramework:start
.localhost:8080
.Changes
FAQ
I see React and Redux are now dependencies. Are we using them in Kibana?
No, they're only used to build the UI Framework documentation site. They make it really easy to add examples of new components. If anybody thinks we should use a different set of tools, suggestions and PRs are welcome!
Why are we using SCSS? We're already using LESS.
SCSS has better mixins, value interpolation, control directives, and other features. We can migrate all of our LESS to SCSS eventually, so we'll only be using one preprocessor.